import sqlalchemy
import pandas as pd
from sqlalchemy import create_engine
import pymysql

print(sqlalchemy.__version__)
print(pymysql.__version__)
pymysql.install_as_MySQLdb()
from sqlalchemy.types import *
from pandas.io import sql

df = pd.DataFrame({"班级":["一年级", "二年级", "三年级", "四年级"],
                   "男生人数":[25, 23, 27, 30],
                   "女生人数":[19, 17, 29, 20]})

print(df)
engine = create_engine('mysql+pymysql://root:123456@localhost:3306/info?charset=utf8')
df.to_sql(name='students', con=engine, if_exists='replace', index=False)
